package com.carkeeper.service.impl;

import com.carkeeper.service.OrderDetailService;
import com.carkeeper.entity.OrderDetailPO;
import com.carkeeper.mapper.OrderDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class OrderDetailServiceImpl implements OrderDetailService{
    @Autowired
    private OrderDetailMapper orderDetailMapper;
    /*
    * 创建订单详情
    * */
    @Override
    public void createOrderDetailService(OrderDetailPO orderDetailPO) {
        orderDetailMapper.insert(orderDetailPO);
    }

    /*
    * 删除订单详情
    * */
    @Override
    public void delByOrderId(Long id) {
        HashMap<String,Object> map = new HashMap<>();
        map.put("order_id",id);
        orderDetailMapper.deleteByMap(map);
    }

    /*
    * 获取订单详情
    * */
    @Override
    public List<OrderDetailPO> getOrderDetail(Long orderId) {
        Map<String,Object> map = new HashMap<>();
        map.put("order_Id",orderId);
        List<OrderDetailPO> orderDetailPOList = orderDetailMapper.selectByMap(map);
        return orderDetailPOList;
    }

}
